import Vue from 'vue'
import Vuex from 'vuex'
Vue.use(Vuex)
import One from './moudles2/One'
import Two from './moudles2/Two'
export default new Vuex.Store({

  state: {
    count: 15,
    name: 'jack',
    list: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
  },
  getters: {
    js (state) {
      return state.list.reduce((item, sum) =>
        item + sum
        , 0)
    }
  },
  mutations: {
    adds (state, obj) {
      state.count += obj.n
    }
    // adds (state, a) {
    //   state.name = a
    // }
  },
  actions: {
    qa (state, obj) {

      setTimeout(() => {
        //点击后延迟一秒执行
        state.commit('adds', obj)
        console.log(1111111)
      }, 1000)
    }

  },
  modules: {
    One,
    Two
  }
})
